<%@ page language="java" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
${aier_doctype}
<html <s:property value="aier-html-xmlns" escape="false"/>>
<head>
<meta http-equiv="Content-Type" content="${aier_content_type}" />
<meta name="keywords" content="${aier_keyworks}" />
<meta name="description" content="${aier_description}" />
<title>${aier_title}</title>
<link rel="stylesheet" href="${aier_css_url}${aier_jqui_css}ui.css" />
<link rel="Stylesheet" href="${aier_css_url}jq/jq.css" />
<link rel="Stylesheet" href="${aier_css_url}jq/multiselect.css" />
<link rel="stylesheet" href="${aier_css_url}social/module/jq-msg.css" />
<link rel="stylesheet" href="${aier_css_url}social/module/reset.css" />
<link rel="stylesheet" href="${aier_css_url}social/school/smanage.css" />

<script type="text/javascript" src="${aier_js_url}j.js"></script>
<script type="text/javascript" src="${aier_js_url}b.js"></script>
<script type="text/javascript" src="${aier_js_url}jq/cn.js"></script>
<script type="text/javascript" src="${aier_js_url}jq/jq.js"></script>
<script type="text/javascript" src="${aier_js_url}jp/hh/ui.js"></script>
<script type="text/javascript" src="${aier_js_url}jp/msg.js"></script>
<script type="text/javascript" src="${aier_js_url}97/WdatePicker.js"></script>
<script type="text/javascript" src="${aier_js_url}lib/block.js"></script>
<script type="text/javascript" src="${aier_js_url}jq/multiselect.js"></script>
<script type="text/javascript" src="${aier_js_url}social/school/attend/smhol.js"></script>
<script type="text/javascript">
	var global_suffix = "${aier_suffix}", global_url = "${aier_url}", global_uri = "${aier_uri}", global_urijs = "${aier_urijs}", 
		global_sid = "${sid}", global_tid = "${tid}";
</script>
</head>
<!-- 假期管理 -->
<body>


	<!-- 顶栏 -->
	<s:action name="userhomecomm_homeHead" namespace="/user"
		executeResult="true"></s:action>

	<!-- 正文 -->
	<div id="hfContent" class="ar-content">
		<div class="content-main">
			<!-- 学校名称栏 -->
			<s:action name="scomm_schoolMTitle" namespace="/school"
				executeResult="true"></s:action>
			<div class="main-content wrap-bg clearfix">
				<!-- 左侧栏 -->
				<s:action name="scomm_schoolMLeft" namespace="/school"
					executeResult="true"></s:action>
				<!-- 右侧内容 -->
				<div class="ae-right">
					<div class="right-main">
						<div class="right-main-top">
							<div class="binfo-title">
								<h3>假期管理</h3>
							</div>
							<div class="right-line"></div>
						</div>
						<div class="right-main-c">
							<div class="info-tab01">
								<table id="inviteParTable">
									<tbody>
										<tr>
											<th class="gray6">起始时间：</th>
											<td><input id="start_txt" class="PY-input" type="text"
												onfocus="WdatePicker({skin:'twoer',dateFmt:'yyyy-MM-dd',readOnly:true})">

											</td>
											<th class="gray6">结束时间：</th>
											<td><input id="end_txt" type="text" class="PY-input"
												onfocus="WdatePicker({skin:'twoer',dateFmt:'yyyy-MM-dd',readOnly:true})">
											</td>
											<td style="width:150px;" align="right"><a id="b_hmsel"
												onclick="search_hol()" href="javascript:;"
												class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only fr"
												role="button" aria-disabled="false"><span
													class="ui-button-text">查询</span> </a></td>
										</tr>
										<tr>
											<td colspan="5" align="right"><a id="hmaddBtn"
												href="javascript:;"
												class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only fr"
												role="button" aria-disabled="false"><span
													class="ui-button-text">添加</span> </a></td>
										</tr>
									</tbody>
								</table>
							</div>
							<div class="right-main-down">
								<div class="down-line"></div>

								<div class="down-inre">
									<table id="holidayinfo"></table>
									<div id="holidaypage"></div>
								</div>
							</div>
						</div>
					</div>
				</div>

			</div>

		</div>
		<!-- footer copyright -->
		<s:action name="userhomecomm_homeFooter" namespace="/user" executeResult="true"></s:action>
		<!-- /footer copyright -->
	</div>

	<!-- 弹出层内容 -->
	<div id="dHolidayadd" title="添加假期" style="display: none;">

		<div class="info-tab01">
			<table>
				<tbody>
					<tr>
						<th class="gray6" valign="top">假期名称：</th>
						<td><input id="txt_brief" type="text"
							class="PY-input"></td>
						<td colspan="2" align="center"><div id="d_hdays" style="visibility: hidden;"><span>假期天数：<span id="span_hdays"></span>天</span></div>
						</td>
					</tr>
					<tr>
						<th class="gray6">开始时间：</th>
						<td><input id="txt_upstart" type="text" class="PY-input"
							onfocus="WdatePicker({skin:'twoer',dateFmt:'yyyy-MM-dd',readOnly:true})">
						</td>
						<th class="gray6">结束时间：</th>
						<td><input id="txt_upend" type="text" class="PY-input"
							onfocus="WdatePicker({skin:'twoer',dateFmt:'yyyy-MM-dd',readOnly:true})">
						</td>					
					</tr>
				</tbody>
			</table>
		</div>
		</div>
		<!-- 提示弹出层 -->
		<div id="holiday_del" style="display: none;" title="撤销假期">
			您确定要将<span id="deltname"></span> 的这条假期信息撤销吗?
		</div>
</body>
<script type="text/javascript">

 
	$(function() {
		var txt_brief = $('#txt_brief'),
		txt_upstart = $('#txt_upstart'),
		txt_upend = $('#txt_upend'),
		allFields = $( [] ).add(txt_brief).add(txt_upstart).add(txt_upend);
		//添加假期弹出层
		$("#dHolidayadd").dialog({
			//背景变暗
			modal: true,
			autoOpen : false,
			show : "fade",
	        hide : "fade",
			width : "670",
			height : "410",
			buttons: {
				"确定": function() {
					addTel();
					$( this ).dialog( "close" );
				},"取消": function() {
					$( this ).dialog( "close" );
				}
			},
		close: function() {
			allFields.val( "" ).removeClass( "ui-state-error" );
			$('#d_hdays').css("visibility", "hidden");
		}
		});
		$("#hmaddBtn").click(function() {
			$("#dHolidayadd").dialog("open");
			return false;
		});
	});
	
	
	
	function search_hol(){
		var sid = "${sid }";
		var txt_sdate = $('#start_txt').val();
		var txt_edate = $('#end_txt').val();
		jQuery("#holidayinfo").jqGrid('setGridParam',{url:"${aier_url}${aier_urijs}schoolhol_search${aier_suffix}?sid="+sid
			+"&txt_sdate="+txt_sdate+"&txt_edate="+txt_edate,page:1}).trigger("reloadGrid");
	}

	function addTel(){
		var sid = "${sid }";
		var txt_sdate_add = $('#txt_upstart').val();
		var txt_edate_add = $('#txt_upend').val();
		var describe_add = $('#txt_brief').val();
		if(txt_sdate_add.trim()==""){
			$().message("请输入假期开始时间");
			return
		}
		if(txt_edate_add.trim()==""){
			$().message("请输入假期结束时间");
			return
		}
		if(txt_edate_add<txt_sdate_add){
			$().message("结束时间必须大于等于开始时间");
			return
		}
		var fun = function(data) {
			if(1==data.s){
				$().message("添加成功,您可以继续添加!");
				$("#holidayinfo").trigger("reloadGrid");
			}else{
				$().message("添加失败,请稍后再试!");
			}
		};
		exeAjax(ajaxUrl("${aier_url}${aier_urijs}schoolhol_add${aier_suffix}"), fun, 
			{"sid" : sid,"describe" :describe_add,"txt_sdate":txt_sdate_add,"txt_edate":txt_edate_add});
				
		
		
	}
	
	
	$('#txt_upend').focus(function() {
	$("#d_hdays").css("visibility", "hidden");
	});
	$("#txt_upend").blur(function (){
		var sadate = $('#txt_upstart').val();
		var eadate = $('#txt_upend').val();
		if(sadate!=""&&eadate!=""&&sadate<=eadate){
			$("#span_hdays").html(daysBetween(sadate,eadate));
			$("#d_hdays").css("visibility", "visible");	
		}
		
	});

	//| 求两个时间的天数差 日期格式为 YYYY-MM-dd   
	function daysBetween(DateOne,DateTwo) 
	{  
	    var OneMonth = DateOne.substring(5,DateOne.lastIndexOf ('-')); 
	    var OneDay = DateOne.substring(DateOne.length,DateOne.lastIndexOf ('-')+1); 
	    var OneYear = DateOne.substring(0,DateOne.indexOf ('-')); 
	    
	    var TwoMonth = DateTwo.substring(5,DateTwo.lastIndexOf ('-')); 
	    var TwoDay = DateTwo.substring(DateTwo.length,DateTwo.lastIndexOf ('-')+1); 
	    var TwoYear = DateTwo.substring(0,DateTwo.indexOf ('-')); 
	    
	    var cha=((Date.parse(OneMonth+'/'+OneDay+'/'+OneYear)- Date.parse(TwoMonth+'/'+TwoDay+'/'+TwoYear))/86400000);   
	    return Math.abs(cha)+1; 
	}
</script>
</html>